package schoolWork.work02.BookBorrowingSystem;

public class Admin {
    String number;
    String name;

    public Admin(String number, String name) {
        this.number = number;
        this.name = name;
    }

    public void addNewBook(Book abook) {
        Books.bookList.add(abook);

    }

    public void lendBook(Reader aReader, Book aBook) {
        //增加该读书借阅这本图书的信息
        BorrowOrderItem theborrow = new BorrowOrderItem(aReader, aBook);
        BorrowOrder.borrowList.add(theborrow);
        //修改这本图书的状态
        aBook.setStatus("外借");

    }

    public void returnBook(Reader aReader, Book aBook) {
        //删除该读者借阅这本书的借阅信息
        int deleteIndex = 0;
        for (int i = 0; i < BorrowOrder.borrowList.size(); i++) {
            if (BorrowOrder.borrowList.get(i).aReader == aReader && BorrowOrder.borrowList.get(i).aBook == aBook)
                deleteIndex = i;
            break;
        }
        BorrowOrder.borrowList.remove(deleteIndex);
        //修改这本图书的状态
        aBook.setStatus("在库");

    }
}


